home *** CD-ROM | disk | FTP | other *** search
/ X User Tools / X User Tools (O'Reilly and Associates)(1994).ISO / sources / xless / xless141.z / xless141 / xless-1.4.1 / functions.c < prev    next >
C/C++ Source or Header  |  1993-02-25  |  1KB  |  63 lines

  1. /*
  2.  * Author: Dave Glowacki
  3.  *       UCB Software Warehouse
  4.  *
  5.  * $Header: /usr/sww/src/X11R5/local/clients/xless-1.4/RCS/functions.c,v 1.8 1993/02/26 01:14:30 dglo Exp $
  6.  */
  7.  
  8. #include "xless.h"
  9.  
  10. static void
  11. okQuitAll(widget, closure, callData)
  12. Widget widget;
  13. XtPointer closure;
  14. XtPointer callData;
  15. {
  16.   XtPopdown((Widget)closure);
  17.   XtDestroyWidget((Widget)closure);
  18.   DestroyAllWindows();
  19.   exit(0);
  20. }
  21.  
  22. static void
  23. cancelQuitAll(widget, closure, callData)
  24. Widget widget;
  25. XtPointer closure;
  26. XtPointer callData;
  27. {
  28.   XtPopdown((Widget)closure);
  29. }
  30.  
  31. static int
  32. QuitAllPrompt()
  33. {
  34.   Widget toplevel;
  35.   static Widget quitall = 0;
  36.  
  37.   /* make sure there's at least one window */
  38.   if (!windowlist)
  39.     return(1);
  40.  
  41.   /* grab first base widget */
  42.   toplevel = windowlist->base;
  43.  
  44.   /* popup warning box */
  45.   if (!quitall)
  46.     quitall = MessageBox(toplevel, "Quit ALL windows?",
  47.                "Cancel", cancelQuitAll, "OK", okQuitAll, 0);
  48.   SetPopup(toplevel, quitall);
  49.   return(0);
  50. }
  51.  
  52. /*
  53.  * clean up, exit application
  54.  */
  55. void
  56. QuitFunction()
  57. {
  58.   if ((windowcount == 1) || QuitAllPrompt()) {
  59.     DestroyAllWindows();
  60.     exit(0);
  61.   }
  62. }
  63.